package com.gsm.controller;

import com.gsm.entity.SysRole;
import com.gsm.service.SysRoleService;
import com.gsm.entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 系统角色表(SysRole)表控制层
 *
 * @author wjq
 * @since 2020-04-26 22:10:05
 */
@RestController
@RequestMapping("sysRole")
public class SysRoleController {
    @Autowired
    private SysRoleService sysRoleService;
    
    /**
     * 新增
     */
    @PostMapping("sysRole")
    public Result insertSysRole(@RequestBody SysRole sysRole) {
        Result result = sysRoleService.insertSysRole(sysRole);
        return result;
    }
    
    /**
     * 根据 id 删除数据
     */
    @DeleteMapping("sysRole/{roleId}")
    public Result deleteSysRoleByRoleId(@PathVariable("roleId")Long roleId) {
        Result result = sysRoleService.deleteSysRoleByRoleId(roleId);
        return result;
    }

    /**
     * 根据 id 修改单条数据
     */
    @PutMapping("sysRole/{roleId}")
    public Result updateSysRoleByRoleId(@PathVariable("roleId")Long roleId, @RequestBody SysRole sysRole) {
        sysRole.setRoleId(roleId);
        Result result = sysRoleService.updateSysRoleByRoleId(sysRole);
        return result;
    }

    /**
     * 根据 id 查询单条数据
     */
    @GetMapping("sysRole/{roleId}")
    public Result selectSysRoleByRoleId(@PathVariable("roleId")Long roleId) {
        Result result = sysRoleService.selectSysRoleByRoleId(roleId);
        return result;
    }
    
    /**
     * 根据条件查询 List
     */
    @GetMapping("sysRoleList")
    public Result selectSysRoleList(SysRole sysRole) {
        Result result = sysRoleService.selectSysRoleList(sysRole);
        return result;
    }
}